From a041c675c7df04f3317524654c18934b61bad8de Mon Sep 17 00:00:00 2001 From: "smh22@firebug.cl.cam.ac.uk" Date: Thu, 17 Nov 2005 10:10:52 +0100 Subject: [PATCH] Fix pinning logic on restore. Signed-off-by: Steven Hand --- tools/libxc/xc_linux_restore.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tools/libxc/xc_linux_restore.c b/tools/libxc/xc_linux_restore.c index 6ca31791c4..88c09c797c 100644 --- a/tools/libxc/xc_linux_restore.c +++ b/tools/libxc/xc_linux_restore.c @@ -146,7 +146,7 @@ int xc_linux_restore(int xc_handle, int io_fd, unsigned long buf[PAGE_SIZE/sizeof(unsigned long)]; struct mmuext_op pin[MAX_PIN_BATCH]; - unsigned int nr_pins = 0; + unsigned int nr_pins; max_pfn = nr_pfns; @@ -501,8 +501,17 @@ int xc_linux_restore(int xc_handle, int io_fd, * Pin page tables. Do this after writing to them as otherwise Xen * will barf when doing the type-checking. */ + nr_pins = 0; for (i = 0; i < max_pfn; i++) { + if (i == (max_pfn-1) || nr_pins == MAX_PIN_BATCH) { + if (xc_mmuext_op(xc_handle, pin, nr_pins, dom) < 0) { + ERR("Failed to pin batch of %d page tables", nr_pins); + goto out; + } + nr_pins = 0; + } + if ( (pfn_type[i] & LPINTAB) == 0 ) continue; @@ -529,16 +538,8 @@ int xc_linux_restore(int xc_handle, int io_fd, } pin[nr_pins].arg1.mfn = p2m[i]; + nr_pins++; - nr_pins ++; - - if (i == (max_pfn-1) || nr_pins == MAX_PIN_BATCH) { - if (xc_mmuext_op(xc_handle, pin, nr_pins, dom) < 0) { - ERR("Failed to pin batch of %d page tables", nr_pins); - goto out; - } - nr_pins = 0; - } } DPRINTF("\b\b\b\b100%%\n"); -- 2.30.2